<template>
  <div class="FoldPanelContainer">
    <div class="upPart">
      <slot name="top">
        <div style="width: 100%; text-align: center; color: white">
          上半展现部分
        </div>
      </slot>
    </div>

    <div class="expand">
      <div @click="toggle" title="展开/收起">
        <el-icon><ArrowLeftBold /></el-icon>
        <el-icon><ArrowRightBold /></el-icon>
      </div>
    </div>

    <div class="downPart" v-show="!isExpand">
      <slot name="bottom">
        <div style="width: 100%; text-align: center; color: white">
          下半隐藏部分
        </div>
      </slot>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import { ArrowLeftBold, ArrowRightBold } from '@element-plus/icons-vue'

const isExpand = ref<boolean>(true)

const toggle = () => (isExpand.value = !isExpand.value)
</script>

<style lang="less" scoped>
.FoldPanelContainer {
  width: calc(100% - 40px);
  border-radius: 12px;
  background-image: linear-gradient(#8e9eab, #bdc3c7);
  padding: 16px 20px;

  > .expand {
    width: calc(100% - 20px);
    padding-left: 10px;
    padding-right: 10px;
    margin-top: 6px;
    margin-bottom: 6px;
    letter-spacing: 1px;
    color: white;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.24);
    border-radius: 6px;

    > div:hover {
      color: #777777;
    }
  }

  > .upPart {
    width: 100%;
  }

  > .downPart {
    width: 100%;
  }
}
</style>
